function calcFun() {
  const arr = [];
  for (let index = 0; index < 99999999; index++) {
    arr.push(index);
  }
  return arr
}

// onmessage事件
onmessage = function (e) {
  const { data } = e;
  const res = calcFun();

  // 将获取的数据通过postMessage发送到主线程
  self.postMessage({
    data: res,
    name: "worker test",
  });
  self.close();
};
